﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="InitLMS.aspx.vb" Inherits="Map.InitLMS" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>日志采集初始化设置</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <link href="/_forms/styles/Form.css" type="text/css" rel="stylesheet">
    <link href="/_common/styles/dialogs.css" type="text/css" rel="stylesheet">
    <link href="/_common/styles/global.css" type="text/css" rel="stylesheet">
	<script language="javascript" src="/_common/scripts/global.js"></script>
	<script language="javascript" src="/_controls/util/util.js"></script>
	<script language="javascript" src="/_forms/FormBase.js"></script>
    <script language="javascript">
        var isEnableLmsOld;
        
			function window.onbeforeunload()
			{
                disableLMS();  
			}
        
        function window.onload()
        {
                if (crmForm.chkDisableLms.checked)
                {
                    isEnableLmsOld = "false";
                }
                else
                {
                    isEnableLmsOld = "true";
                }
        }
        
        //初始化日志管理系统
        function initLMS() 
        {        
            var xmlDom = new ActiveXObject("Microsoft.XMLDOM");
            var sFile,sReturn,sResult;
             
            //检测日志管理的数据库是否可以正常访问
            try
            {
			    sFile = "/Pub_XmlHttp.aspx"; 
			    sReturn = GetDataByXMLHTTP(sFile,"CheckLmsDBConnect","","");
                
                xmlDom.loadXML(sReturn);
                sResult = xmlDom.documentElement.attributes.getNamedItem("result").value;
                
                if (sResult.toLowerCase() == "false")
                {
                    alert(xmlDom.documentElement.attributes.getNamedItem("errormessage").value);
                    return;
                }            
            }
            catch (e) 
            {
                alert("连接日志管理数据库失败，无法进行初始化！");
                return;
            }
            
            //检测日志管理是否已经被初始化
			sFile = "/Pub_XmlHttp.aspx"; 
			sReturn = GetDataByXMLHTTP(sFile,"CheckIsInitedLms","","");
			
			if (sReturn == "true")
			{
			    //如果已经初始化，则退出    
                alert("日志管理已初始化，不需重复进行！");
                return;
			}
			else if (sReturn != "false") 
			{
                alert("获取日志管理初始化状态失败，无法进行初始化！");
                return;
			}  
			
		    //如果没有初始化，则进行初始化		
            try 
            {
		        sFile = "/Pub_XmlHttp.aspx"; 
		        sReturn = GetDataByXMLHTTP(sFile,"InitLMS","","");

                xmlDom.loadXML(sReturn);
                sResult = xmlDom.documentElement.attributes.getNamedItem("result").value;
                if (sResult.toLowerCase() == "true") 
                {
                    //初始化成功，则退出
                     alert("日志管理初始化已完成！");
                     return;
                }
                else 
                {
                    //初始化失败，则显示失败明细原因
                    alert(xmlDom.documentElement.attributes.getNamedItem("errormessage").value);
                    return;
                }
            }
            catch (e) 
            {
                alert("日志管理初始化失败！");
                return;
            }

			      
        }        
        
        
        //暂不启用日志管理
        function disableLMS() 
        {
            var isEnableLms;
            if (crmForm.chkDisableLms.checked)
            {
                isEnableLms = "false";
            }
            else
            {
                isEnableLms = "true";            
            }
            
            if (isEnableLms != isEnableLmsOld)
            {                    
			    var strFile = "Pub_XmlHttp.aspx"; 
			    var sReturn=GetDataByXMLHTTP(strFile,"DisableLMS",isEnableLms,"");
    			
   			    if (sReturn != "true") 
   			    {
   			        if (crmForm.chkDisableLms.checked)
   			        {
   			            alert("设置暂不启用日志管理失败！");
   			        }
   			        else
   			        {
   			            alert("取消暂不启用日志管理失败！");
   			        }
   			    }            
            }
            
            
        }        
    </script>
</head>
<body ms_positioning="GridLayout"">
<form class="map" id="crmForm" method="post" runat="server">
	<table height="100%" cellSpacing="0" cellPadding="0" width="100%">
		<tr>
			<td colspan="2" class="main" align="center" valign=top>
				<table cellSpacing="0" width="90%">
						<tr height="30">
							<td>启用日志管理的采集功能之前，需要进行以下初始化设置：</td>
						</tr>
						<tr>
							<td >
                                1）设置日志采集的ERP网站<br />
                                2）记录日志管理数据库服务器的IP地址<br />
                                3）创建及设置调度采集日志的作业计划<br />
							</td>
						</tr>
						<tr height="50">
						<td>点击 <a href="#" onclick="initLMS();">初始化日志采集功能</a> ，系统自动完成初始化设置。</td>
						</tr>
					</TBODY>
				</table>
			</td>
		</tr>
		<tr height="50">
		    <td>
            &nbsp;&nbsp;<asp:CheckBox ID="chkDisableLms" runat="server" /><label for="chkDisableLms">暂不启用日志管理</label></td>
			<td class="buttons">
					<button id="btnClose" style="WIDTH: 70px" onclick="parent.window.close();" name="btnClose"
					type="button" value="关 闭">关 闭</button>
			</td>
		</tr>
	</table>
</form>
</body>
</html>
